home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Archives / Converters / new2ps.lha / new2ps.c next >
Encoding:
C/C++ Source or Header  |  1992-05-28  |  1.2 KB  |  51 lines

  1. /****************************************************************/
  2. /*                                */
  3. /*    NEWIO to POSTSCRIPT conversion filter            */
  4. /*                                */
  5. /*    by Tom Heynemann, May 1992                */
  6. /*       email: tom@nice.usergroup.ethz.ch            */
  7. /*                                */
  8. /*    look at .doc file for correct NewIO settings        */
  9. /*                                */
  10. /****************************************************************/
  11.  
  12. #include <stdio.h>
  13. #include <string.h>
  14.  
  15. int main(int argc, char *argv[])
  16. {
  17.     FILE    *fp_in = NULL, *fp_out = NULL;
  18.     int    x, y;
  19.     char    str[8], tmp1[32], tmp2[32];
  20.  
  21.     if (argc != 3) {
  22.         printf("Usage: %s <infile> <outfile>\n", argv[0]);
  23.         return -1;
  24.     } else {
  25.         if (NULL == (fp_in = fopen(argv[1],"r"))) {
  26.             printf("Could not open input file %s !\n",
  27.                 argv[1]);
  28.             return -2;
  29.         } else {
  30.             if (NULL == (fp_out = fopen(argv[2],"w"))) {
  31.                 printf("Could not open output file %s !\n",
  32.                     argv[2]);
  33.                 return -2;
  34.             }
  35.         }
  36.     }
  37.     fprintf(fp_out,"%%! PS-Adobe\n.072 .072 scale\n600 600 translate\
  38.         \nnewpath\n8 setlinewidth\n");
  39.     while (!feof(fp_in)) {
  40.         fscanf(fp_in," %s %d %d", str, &x, &y);
  41.         strcpy(tmp2,tmp1);
  42.         sprintf(tmp1,"%1d %1d %s\n", x, y, str);
  43.         if ( strcmp(tmp1,tmp2) )
  44.             fprintf(fp_out,tmp1);
  45.     }
  46.     fprintf(fp_out,"stroke\nshowpage\n");
  47.     fclose(fp_in);
  48.     fclose(fp_out);
  49.     return 1;
  50. }
  51.